package com.tzg157.fitness;

import com.tzg157.fitness.kafka.KafkaReceiver;
import com.tzg157.fitness.kafka.MsgReceiver;
import com.tzg157.fitness.kafka.RealMsgReceiver;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.EnableScheduling;

@Slf4j
@RequiredArgsConstructor
@SpringBootApplication
@EnableScheduling
public class RecommenderApplication implements ApplicationListener<ApplicationReadyEvent> {

    private final KafkaReceiver kafkaReceiver;
    private final MsgReceiver msgReceiver;
    private final RealMsgReceiver realMsgReceiver;

    public static void main( String[] args ) {
        SpringApplication.run(RecommenderApplication.class, args);
    }

    @Override
    public void onApplicationEvent(ApplicationReadyEvent event) {
        try {
            log.info("event:{}",event);
//            kafkaReceiver.receive();
//            msgReceiver.receive();
            realMsgReceiver.receive();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}
